f[x_] := x^2 - 50

g[x_]:=((x Sin[x] Log[x/2]-1)/Sqrt[1+x^2])^2

h[x_]:=x^2-3

ournewton[fun_, init_, eps_] :=Module[{a = init, cnt = 0},
	While[ Abs[fun[a]] > eps,
		cnt = cnt + 1;
    Print["approximation ", cnt, ": ", a];
		a = N[a - fun[a] / fun'[a]]];
{a, cnt}]

ournewton[f, 50, 10^(-7)]

f[%[[1]]]

Plot[g[x],{x,-10,10}]

ournewton[g,10, 10^(-8)]

g[%[[1]]]

ournewton[h,1, 0.00001]

h[%[[1]]]

h[x]

{h',FullForm[h']}

betternewton[fun_,init_,itermax_:100]:=Module[{fd=fun',n=N[init]},
		FixedPointList[(#-fun[#]/fd[#])&, n, itermax]]

betternewton[h,2]

betternewton[g,6, 18]